package models;

import java.util.Comparator;

public class Card {
	
	public Rank rank;
	public Suit suit;
	public int id;
	
	
	public Card(Rank rank, Suit suit)
	{
		this.rank = rank;
		this.suit = suit;
		this.id = rank.toInteger() + suit.toInteger();		
	}
	
	public boolean equals(Object o)
	{
		if (o instanceof Card)
		{
			Card c = (Card)o;
			return this.id == c.id;
		}
		return o.equals(this);
	}
	
	public String toString()
	{
		return rank.toString() + " of " + suit.toString();
	}
	
	public static class CardComparator implements Comparator<Card>
	{

		@Override
		public int compare(Card o1, Card o2) {
			if (o1.id < o2.id)
				return -1;
			else if (o1.id == o2.id)
				return 0;
			else
				return 1;
			
		}
		
	}

}
